package com.yunkuhui.www.demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

@RestController
public class TestThrowExceptionController {

	@RequestMapping("/div")
	public double divisionNumber(int n) {
		System.out.println("n = " + n);
		System.out.println("444444444444444444444444444444444444444");
		return (double) (10 / n);
	}

	@RequestMapping("/out")
	public Map<String, Integer> subscriptCrossover(int index) {
		int[] nums = {0, 1, 2, 3, 4};
		HashMap<String, Integer> map = new HashMap<>();
		map.put("num", nums[index]);
		return map;
	}

	@RequestMapping("/emp")
	public String ioNull(MultipartFile file) throws IOException {
		InputStream in = file.getInputStream();
		in.close();
		return "";
	}
}
